package com.trace.app.controller;


import com.trace.app.entity.DTO.RawProDTO;
import com.trace.app.entity.RawPro;
import com.trace.app.entity.ResponseResult;
import com.trace.app.service.RawProService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (RawPro)表控制层
 *
 * @author lionkliu
 * @since 2024-04-21 13:27:35
 */
@RestController
@RequestMapping("rawPro")
public class RawProController {

    @Resource
    private RawProService rawProService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return rawProService.selectPage(pageNum, pageSize);
    }

    @GetMapping("/label/{proId}")
    public ResponseResult getRawLabelValueByProId(@PathVariable Long proId) {
        return rawProService.getRawLabelValueByProId(proId);
    }

    @GetMapping("/list")
    public ResponseResult list() {
        return ResponseResult.okResult(rawProService.list());
    }

    @GetMapping("{proId}")
    public ResponseResult getRawByProId(@PathVariable Integer proId) {
        return rawProService.getRawByProId(proId);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody RawPro rawPro) {
        return rawProService.insertOne(rawPro);
    }

    @PostMapping("/batch")
    public ResponseResult insertBatch(@RequestBody RawProDTO rawProDTO) {
        return rawProService.insertBatch(rawProDTO);
    }

    @PutMapping
    public ResponseResult update(@RequestBody RawPro rawPro) {
        return rawProService.updateOne(rawPro);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return rawProService.deleteById(id);
    }

}
